package com.c8a.validation.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.Date;

/**
 * @Author C8A
 * @Date 2022-04-23 20:35
 * @Email 1912327276@qq.com
 */

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Teacher implements Serializable {
    @NotNull
    private Integer id;

    @NotEmpty
    private String name;

    @NotEmpty
    @Size(min = 8,max = 20,message = "密码长度必须在8到20之间")
    private String password;

    /**
     * @Email: 邮箱校验注解不能为空,格式必须正确
     */
    @Email(message = "请输入正确的邮箱")
    private String email;

    /**
     * 是否校验
     * @AssertTrue: 必须是true可以是字符串
     */
    @AssertTrue
    private Boolean isValid;

    /**
     * 是否失效
     * @AssertFalse: false
     */
    @AssertFalse
    private Boolean isInvalid;

    /**
     * @PositiveOrZero :元素必须是正数or零
     */
    @PositiveOrZero
    private Integer sort;

    /**
     * @Positive: 元素必须是正数
     */
    @Positive
    private Integer orderByAt;

    /**
     * @PastOrPresent: 过去时间或当前时间
     * 还有个伴生注解@Past: 必须是过去时间
     * 示例: 2019-11-30 19:30:00 or 2021-09-11 00:00:00
     */
    @PastOrPresent
    @JsonFormat(shape= JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
    private Date startDate;

    /**
     * @FutureOrPresent: 当前时间或未来时间
     * 伴生注解@Future: 必须是未来时间
     * 示例: 2021-09-11 00:00:00 or 2021-11-30 19:30:00
     */
    @FutureOrPresent
    @JsonFormat(shape= JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
    private Date endDate;
}
